package com.ruoyi.project.jiaqin.memberquotationclass.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.jiaqin.memberquotationclass.domain.MemberQuoteClass;
import com.ruoyi.project.jiaqin.memberquotationclass.service.IMemberQuoteClassService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 用户关注分类Controller
 * 
 * @author admin
 * @date 2021-01-09
 */
@Controller
@RequestMapping("/jiaqin/memberquotationclass")
public class MemberQuoteClassController extends BaseController
{
    private String prefix = "jiaqin/memberquotationclass";

    @Autowired
    private IMemberQuoteClassService memberQuoteClassService;

    @RequiresPermissions("jiaqin:memberquotationclass:view")
    @GetMapping()
    public String memberquotationclass()
    {
        return prefix + "/memberquotationclass";
    }

    /**
     * 查询用户关注分类列表
     */
    @RequiresPermissions("jiaqin:memberquotationclass:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(MemberQuoteClass memberQuoteClass)
    {
        startPage();
        List<MemberQuoteClass> list = memberQuoteClassService.selectMemberQuoteClassList(memberQuoteClass);
        return getDataTable(list);
    }

    /**
     * 导出用户关注分类列表
     */
    @RequiresPermissions("jiaqin:memberquotationclass:export")
    @Log(title = "用户关注分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(MemberQuoteClass memberQuoteClass)
    {
        List<MemberQuoteClass> list = memberQuoteClassService.selectMemberQuoteClassList(memberQuoteClass);
        ExcelUtil<MemberQuoteClass> util = new ExcelUtil<MemberQuoteClass>(MemberQuoteClass.class);
        return util.exportExcel(list, "memberquotationclass");
    }

    /**
     * 新增用户关注分类
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存用户关注分类
     */
    @RequiresPermissions("jiaqin:memberquotationclass:add")
    @Log(title = "用户关注分类", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(MemberQuoteClass memberQuoteClass)
    {
        return toAjax(memberQuoteClassService.insertMemberQuoteClass(memberQuoteClass));
    }

    /**
     * 修改用户关注分类
     */
    @GetMapping("/edit/{memberId}")
    public String edit(@PathVariable("memberId") String memberId, ModelMap mmap)
    {
        MemberQuoteClass memberQuoteClass = memberQuoteClassService.selectMemberQuoteClassById(memberId);
        mmap.put("memberQuoteClass", memberQuoteClass);
        return prefix + "/edit";
    }

    /**
     * 修改保存用户关注分类
     */
    @RequiresPermissions("jiaqin:memberquotationclass:edit")
    @Log(title = "用户关注分类", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(MemberQuoteClass memberQuoteClass)
    {
        return toAjax(memberQuoteClassService.updateMemberQuoteClass(memberQuoteClass));
    }

    /**
     * 删除用户关注分类
     */
    @RequiresPermissions("jiaqin:memberquotationclass:remove")
    @Log(title = "用户关注分类", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(memberQuoteClassService.deleteMemberQuoteClassByIds(ids));
    }
}
